package com.swak.reactivex.transport;

import java.util.Collection;

import com.swak.exception.RemotingException;
import com.swak.exception.ServerException;
import com.swak.registry.URL;

/**
 * 定义一个服务器
 *
 * @author: lifeng
 * @date: 2020/3/29 12:16
 */
public interface Server {

	/**
	 * 服务器的URL
	 * @return
	 */
	URL url();

	/**
	 * get channels.
	 *
	 * @return channels
	 */
	Collection<Channel> getChannels();

	/**
	 * Starts the web server. Calling this method on an already started server has
	 * no effect.
	 *
	 * @throws ServerException 服务器异常
	 */
	void start() throws ServerException;

	/**
	 * close the web server. Calling this method on an already stopped server has no
	 * effect.
	 *
	 * @throws ServerException 务器异常
	 */
	void close() throws ServerException;

	/**
	 * 发送消息
	 * 
	 * @param message
	 * @param sent
	 * @throws RemotingException
	 */
	void send(Object message, boolean sent) throws RemotingException;
}
